package com.wut.clock.common.util;

/**
 * @author ZYH
 * @unit D9Lab
 * @description 生成redisKey的工具
 * @date 2022/6/2 9:51
 */
public class RedisKeyUtil {

    private static final String SPLIT = ":";
    private static final String PREFIX_UV = "uv";  //UV(Unique Visitor)
    private static final String PREFIX_DAU = "dau"; //DAU(Daily Active User)
    private static final String PREFIX_LIKE_ENTITY = "like:entity";     //文章或评论点赞量
    private static final String PREFIX_LIKE_USER = "like:user";     //用户的总获赞数
    private static final String PREFIX_DISLIKE_ENTITY = "dislike:entity";       //文章或评论的点踩量
    private static final String PREFIX_DISLIKE_USER = "dislike:user";       //用户的总被踩数
    private static final String ARTICLE_VIEWS_COUNT = "article_views_count";     //文章浏览量
    private static final String PREFIX_ARTICLE_SCORE = "article"; // 文章分数的key

    // 单日uv
    public static String getUVKey(String date){
        return PREFIX_UV+SPLIT+date;
    }

    // 区间uv
    public static String getUVKey(String startDate,String endDate){
        return PREFIX_UV+SPLIT+startDate+SPLIT+endDate;
    }

    //单日活跃用户
    public static String getDAUKey(String date){
        return PREFIX_DAU+SPLIT+date;
    }

    //区间活跃用户
    public static String getDAUKey(String startDate,String endDate){
        return PREFIX_DAU+SPLIT+startDate+SPLIT+endDate;
    }

    // 实体点赞的key
    public static String getEntityLikeKey(Integer entityId,Integer entityType){ return PREFIX_LIKE_ENTITY +SPLIT+entityId +SPLIT+entityType; }

    // 用户点赞的key
    public static String getUserLikeKey(Integer userId) {return PREFIX_LIKE_USER + SPLIT + userId;}

    // 实体点踩的key
    public static String getEntityDislikeKey(Integer entityId,Integer entityType){ return PREFIX_DISLIKE_ENTITY + SPLIT + entityId + SPLIT + entityType; }

    // 用户点踩的key
    public static String getUserDislikeKey(Integer userId) {return PREFIX_DISLIKE_USER + SPLIT + userId;}

    //文章浏览量的key
    public static String getArticleViewsCountKey(Integer articleId) {
        return ARTICLE_VIEWS_COUNT + SPLIT + articleId;
    }

    public static String getArticleScore() { return PREFIX_ARTICLE_SCORE + "score"; }
}
